<!--ID:accound-->
<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../libs/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../../libs/app.css" />
		<link href="../../css/main.css" rel="stylesheet" />
		<link href="../../css/account.css" rel="stylesheet" />
	</head>

	<body>
		<div class="head">
			<img class="mui-action-back" src="../../images/all-left.png" alt="">
			<p>结算</p>
		</div>

		<div class="mui-scroll-wrapper">
			<div class="mui-scroll">
				<div class="content"></div>
			</div>
		</div>

		<div class="accound">
			<div class="all-pay">
				<p>共<span class="alldan"></span>件，合计：<span class="red">¥<span class="allprice"></span></span>
				</p>
			</div>
			<div class="gotoSure_hook">提交订单</div>
		</div>

		<script src="../../libs/mui.min.js"></script>
		<script src="../../js/jquery-3.1.1.min.js"></script>
		<script src="../../js/url.js"></script>
		<script>
            $(function () {
                var vip = localStorage.vip == 'true' ? true : false;
                getcar(vip);

                window.addEventListener('Clear', function() {
                    $('.content').empty();
                    $('.allprice').text(0);
                    localStorage.sureallprice = 0;
                    $('.alldan').text(0);
                });
            });

            mui('.mui-scroll-wrapper').scroll({ deceleration: 0.0010 });

			function getcar(v) {
				$.ajax({
						url: ur + 'rest/productController/list-order',
						type: 'GET',
						headers: {
							"X-Token": localStorage.token
						},
						dataType: 'json',
						data: '',
					})
					.done(function(data) {
						if(data.meta.code === 'S002') {
							var n = data.data.list.length;
							$('.alldan').text(n);
							localStorage.surehow = n;
							if(n > 0) {
								var allprice = 0;
								for(var i = 0; i < n; i++) {
									var div = $('<div class="content-d"> ' +
										'<p>' + data.data.list[i].productName + '</p> ' +
										'<div> <img src=' + ur + data.data.list[i].productImg + ' alt=""> </div> ' +
										'<p>共<span>' + data.data.list[i].size + '</span>件，价格：<span class="red">¥<span>' + data.data.list[i].price + '</span></span></p> ' +
										'</div>');
									$('.content').append(div);
									allprice = allprice + (v ? data.data.list[i].vipPrice : data.data.list[i].price) * data.data.list[i].size;
								}
								$('.allprice').text(allprice); // 写入显示交易价格
								localStorage.sureallprice = allprice;
								gotoSure_init(); // 不影响交易价格 但确保显示正确
							} else if(n == 0) {
								mui.toast('没有更多');
							}
						} else {
							mui.toast(data.meta.message);
						}
					})
			}

			function gotoSure_init() {
				$(document).on('tap', '.gotoSure_hook', function() {
					href('sure.html');
				});
			}
		</script>

	</body>

</html>